package com.jhd.fuzhou.util;

import android.os.CountDownTimer;
import android.widget.TextView;

import com.jhd.fuzhou.R;

public class TimeCount extends CountDownTimer {

    private TextView btnIphoneCode;

    public TimeCount(long millisInFuture, long countDownInterval, TextView btnIphoneCode) {
        super(millisInFuture, countDownInterval);
        this.btnIphoneCode = btnIphoneCode;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        btnIphoneCode.setClickable(false);
        btnIphoneCode.setBackgroundResource(R.drawable.card_border_default);
        btnIphoneCode.setText(millisUntilFinished / 1000 + "s后重试");
        btnIphoneCode.setTextColor(btnIphoneCode.getResources().getColor(R.color.colorGrey));
    }

    @Override
    public void onFinish() {
        btnIphoneCode.setClickable(true);
        btnIphoneCode.setBackgroundResource(R.drawable.card_border_select);
        btnIphoneCode.setText("获取验证码");
        btnIphoneCode.setTextColor(btnIphoneCode.getResources().getColor(R.color.colorCyan500));
    }

}
